<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "ecs_users".
 *
 * @property integer $user_id
 * @property string $email
 * @property string $user_name
 * @property string $password
 * @property string $question
 * @property string $answer
 * @property integer $sex
 * @property string $birthday
 * @property string $user_money
 * @property string $frozen_money
 * @property double $pay_points
 * @property string $rank_points
 * @property string $address_id
 * @property string $reg_time
 * @property string $last_login
 * @property string $last_time
 * @property string $last_ip
 * @property integer $visit_count
 * @property integer $user_rank
 * @property integer $is_special
 * @property string $ec_salt
 * @property string $salt
 * @property integer $parent_id
 * @property integer $flag
 * @property string $alias
 * @property string $msn
 * @property string $qq
 * @property string $office_phone
 * @property string $home_phone
 * @property string $mobile_phone
 * @property integer $is_validated
 * @property string $credit_line
 * @property string $passwd_question
 * @property string $avatar
 * @property string $passwd_answer
 * @property string $nickname
 * @property integer $age
 * @property string $blood
 * @property string $ill_history
 * @property integer $height
 * @property double $weight
 * @property string $area
 * @property string $like_main_food
 * @property string $like_second_food
 * @property string $tag
 * @property string $professional
 * @property string $update_time
 * @property string $create_time
 * @property integer $country
 * @property integer $province
 * @property integer $login_status
 * @property integer $city
 * @property integer $open_id
 * @property integer $login_type
 *
 * @property TDoctorAppointmentOrder[] $tDoctorAppointmentOrders
 * @property TDoctorComment[] $tDoctorComments
 * @property TDoctorMessage[] $tDoctorMessages
 * @property TDoctorMessageOrder[] $tDoctorMessageOrders
 * @property TDoctorPrivateOrder[] $tDoctorPrivateOrders
 * @property TDoctorUserAuth[] $tDoctorUserAuths
 * @property TDoctorUserPrivate[] $tDoctorUserPrivates
 * @property TInformationUserCollection[] $tInformationUserCollections
 * @property TInformationUserThumb[] $tInformationUserThumbs
 * @property TPersonalSetting[] $tPersonalSettings
 */
class EcsUsers extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'ecs_users';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['sex', 'rank_points', 'address_id', 'reg_time', 'last_login', 'visit_count', 'user_rank', 'is_special', 'parent_id', 'flag', 'is_validated', 'age', 'height', 'country', 'province', 'login_status', 'city'], 'integer'],
            [['birthday', 'last_time', 'update_time', 'create_time'], 'safe'],
            [['user_money', 'frozen_money', 'pay_points', 'credit_line', 'weight','login_type'], 'number'],
            [['ill_history', 'tag','open_id'], 'string'],
            [['email', 'user_name', 'alias', 'msn'], 'string', 'max' => 60],
            [['password'], 'string', 'max' => 32],
            [['question', 'answer', 'passwd_answer', 'like_main_food', 'like_second_food'], 'string', 'max' => 255],
            [['last_ip'], 'string', 'max' => 15],
            [['ec_salt', 'salt'], 'string', 'max' => 10],
            [['qq', 'office_phone', 'home_phone', 'mobile_phone'], 'string', 'max' => 20],
            [['passwd_question', 'nickname', 'blood'], 'string', 'max' => 50],
            [['avatar'], 'string', 'max' => 200],
            [['area', 'professional'], 'string', 'max' => 100],
            [['user_name'], 'unique'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'user_id' => Yii::t('app', 'User ID'),
            'email' => Yii::t('app', 'Email'),
            'user_name' => Yii::t('app', 'User Name'),
            'password' => Yii::t('app', 'Password'),
            'question' => Yii::t('app', 'Question'),
            'answer' => Yii::t('app', 'Answer'),
            'sex' => Yii::t('app', 'Sex'),
            'birthday' => Yii::t('app', 'Birthday'),
            'user_money' => Yii::t('app', 'User Money'),
            'frozen_money' => Yii::t('app', 'Frozen Money'),
            'pay_points' => Yii::t('app', 'Pay Points'),
            'rank_points' => Yii::t('app', 'Rank Points'),
            'address_id' => Yii::t('app', 'Address ID'),
            'reg_time' => Yii::t('app', 'Reg Time'),
            'last_login' => Yii::t('app', 'Last Login'),
            'last_time' => Yii::t('app', 'Last Time'),
            'last_ip' => Yii::t('app', 'Last Ip'),
            'visit_count' => Yii::t('app', 'Visit Count'),
            'user_rank' => Yii::t('app', 'User Rank'),
            'is_special' => Yii::t('app', 'Is Special'),
            'ec_salt' => Yii::t('app', 'Ec Salt'),
            'salt' => Yii::t('app', 'Salt'),
            'parent_id' => Yii::t('app', 'Parent ID'),
            'flag' => Yii::t('app', 'Flag'),
            'alias' => Yii::t('app', 'Alias'),
            'msn' => Yii::t('app', 'Msn'),
            'qq' => Yii::t('app', 'Qq'),
            'office_phone' => Yii::t('app', 'Office Phone'),
            'home_phone' => Yii::t('app', 'Home Phone'),
            'mobile_phone' => Yii::t('app', 'Mobile Phone'),
            'is_validated' => Yii::t('app', 'Is Validated'),
            'credit_line' => Yii::t('app', 'Credit Line'),
            'passwd_question' => Yii::t('app', 'Passwd Question'),
            'avatar' => Yii::t('app', 'Avatar'),
            'passwd_answer' => Yii::t('app', 'Passwd Answer'),
            'nickname' => Yii::t('app', 'Nickname'),
            'age' => Yii::t('app', 'Age'),
            'blood' => Yii::t('app', 'Blood'),
            'ill_history' => Yii::t('app', 'Ill History'),
            'height' => Yii::t('app', 'Height'),
            'weight' => Yii::t('app', 'Weight'),
            'area' => Yii::t('app', 'Area'),
            'like_main_food' => Yii::t('app', 'Like Main Food'),
            'like_second_food' => Yii::t('app', 'Like Second Food'),
            'tag' => Yii::t('app', 'Tag'),
            'professional' => Yii::t('app', 'Professional'),
            'update_time' => Yii::t('app', 'Update Time'),
            'create_time' => Yii::t('app', 'Create Time'),
            'country' => Yii::t('app', 'Country'),
            'province' => Yii::t('app', 'Province'),
            'login_status' => Yii::t('app', 'Login Status'),
            'city' => Yii::t('app', 'City'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTDoctorAppointmentOrders()
    {
        return $this->hasMany(TDoctorAppointmentOrder::className(), ['user_id' => 'user_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTDoctorComments()
    {
        return $this->hasMany(TDoctorComment::className(), ['user_id' => 'user_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTDoctorMessages()
    {
        return $this->hasMany(TDoctorMessage::className(), ['user_id' => 'user_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTDoctorMessageOrders()
    {
        return $this->hasMany(TDoctorMessageOrder::className(), ['user_id' => 'user_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTDoctorPrivateOrders()
    {
        return $this->hasMany(TDoctorPrivateOrder::className(), ['user_id' => 'user_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTDoctorUserAuths()
    {
        return $this->hasMany(TDoctorUserAuth::className(), ['user_id' => 'user_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTDoctorUserPrivates()
    {
        return $this->hasMany(TDoctorUserPrivate::className(), ['user_id' => 'user_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTInformationUserCollections()
    {
        return $this->hasMany(TInformationUserCollection::className(), ['user_id' => 'user_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTInformationUserThumbs()
    {
        return $this->hasMany(TInformationUserThumb::className(), ['user_id' => 'user_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTPersonalSettings()
    {
        return $this->hasMany(TPersonalSetting::className(), ['user_id' => 'user_id']);
    }

    /**
     * @inheritdoc
     * @return \app\models\query\EcsUsersQuery the active query used by this AR class.
     */
    public static function find()
    {
        return new \app\models\query\EcsUsersQuery(get_called_class());
    }
}
